<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>登录</title>
        <script src="js/jquery-3.3.1.js"></script>
        <script>

            $(function () {

                //登录
                $("#loinForm").submit(function () {
                    $.post("loginServlet", $(this).serialize(), function (info) {
                        if(info.flag){
                            location.href="index.html";
                        }else{
                            alert(info.errorMsg)
                        }
                    });

                    return false;//禁止提交
                });






                //更新验证码
                $("#checkCodeImg").click(function () {
                    this.src = "checkCodeServlet?time=" + new Date().getTime();
                });
            })


        </script>
    </head>
    <body>
        <h2>登录</h2>
        <form action="loginServlet" id="loinForm">
            用户名:<input type="text" name="username"><br>
            密码:<input type="password" name="password"><br>
            验证码:<input type="text" name="checkcode">    <img src="checkCodeServlet" id="checkCodeImg"><br>
            <input type="submit" value="登录" >
        </form>


    </body>
</html>
